/*
//  Copyright © 2014 Allen County Public Library.

  //        ACPL Mobile is free software: This program is distributed and you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.  ACPL Mobile is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, including without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with ACPL Mobile. If not, see http://www.gnu.org/licenses/.
 * Author: James Harpe
 * 
 * Description: This class provides a simple object representation of a checkout.
 * 
 */

package us.in.lib.acpl.Mobile_ACPL.patron;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Checkout implements Comparable {
	private String itemId;
	private String callNumber;
	private String title;
	private String author;
	private Date checkoutDate;
	private Date dueDate;
	private String timesRenewed;
	private boolean overdue;

	public String getItemId() {
		return itemId;
	}

	public void setItemId(String itemId) {
		this.itemId = itemId;
	}

	public String getCallNumber() {
		return callNumber;
	}

	public void setCallNumber(String callNumber) {
		this.callNumber = callNumber;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public Date getCheckoutDate() {
		return checkoutDate;
	}

	public void setCheckoutDate(String checkoutDate) {
		SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
		try {
			this.dueDate = parser.parse(checkoutDate);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public Date getDueDate() {
		return dueDate;
	}

	public void setDueDate(String dueDate) {
		// dueDate= dueDate.substring(0, 19)+" "+dueDate.substring(19);
		SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
		try {
			this.dueDate = parser.parse(dueDate);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public String getTimesRenewed() {
		return timesRenewed;
	}

	public void setTimesRenewed(String timesRenewed) {
		this.timesRenewed = timesRenewed;
	}

	public boolean isOverdue() {
		return overdue;
	}

	public void setOverdue(boolean overdue) {
		this.overdue = overdue;
	}

	@Override
	public int compareTo(Object other) {
		// TODO Auto-generated method stub
		Checkout otherCO = (Checkout)other;
		return dueDate.compareTo(otherCO.dueDate);
//		if(dueDate.before(otherCO.dueDate)){
//			return -1;
//		}else{
//			return 1;
//		}

	}
	

}
